package com.example.drawerlayoutleftright;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.drawerlayout.widget.DrawerLayout;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private DrawerLayout drawerLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        drawerLayout = findViewById(R.id.drawerlayout);
        drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
            //当抽屉位置发生变化时调用
            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {

            }

            //当抽屉处于完全打开时调用
            @Override
            public void onDrawerOpened(View drawerView) {

            }

            //当抽屉处于完全关闭时调用
            @Override
            public void onDrawerClosed(View drawerView) {

            }

            //抽屉滑动状态改变时调用
            //状态值   STATE_IDLE：闲置、STATE_DRAGGING：拖拽、STATE_SETTLING：固定的
            @Override
            public void onDrawerStateChanged(int newState) {

            }
        });

        //drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); //关闭手势滑动
        //drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); //打开手势滑动
    }
}